package com.wsl.aop.security;

import com.wsl.aop.service.AuthService;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author ：wangshuliang
 * @date ：Created in 2019/6/4 8:27
 * @description：安全切面验证
 * @modified By：
 */
@Aspect
@Component
public class SecurityAspect {
    @Autowired
    private AuthService authService;
    /**
     * 根据注解进行切面的限定
     */
    @Pointcut("@annotation(AdminOnly)")
    public void adminOnly() {

    }

    @Before("adminOnly()")
    public void check() {
        authService.checkAccess();
    }
}
